import 'package:flutter/material.dart';
import '../../common_layouts/contact_item_lay.dart';
import '../../model/contacts_info.dart';
import '../../Constants/constants.dart';

//联系人
class ContactsPage extends StatefulWidget {
  @override
  _ContactsPageState createState() => _ContactsPageState();
}

//页面保持
class _ContactsPageState extends State<ContactsPage>  with AutomaticKeepAliveClientMixin{
  @override
  bool get wantKeepAlive => true;

  List<ContactsInfo> _contactsInfos = [];

  //4个表头
  List<ContactsInfo> _listTopFourInfos = [
    ContactsInfo("",null,'新的朋友',true,'assets/images/ima_new_friend.png'),
    ContactsInfo("",null,'群聊',true,'assets/images/ima_group_chat.png'),
    ContactsInfo("",null,'标签',true,'assets/images/ima_tag.png'),
    ContactsInfo("",null,'公众号',true,'assets/images/ima_public_account.png'),
  ];

  @override
  Widget build(BuildContext context) {
    print('页签...');
    //_contactsInfos.clear();
    _contactsInfos.addAll(_listTopFourInfos);
    _contactsInfos.add(ContactsInfo("A","A",'阿三',true,'assets/images/ima_new_friend.png'));
    _contactsInfos.add(ContactsInfo("A",null,'阿六',true,'assets/images/ima_new_friend.png'));
    _contactsInfos.add(ContactsInfo("A",null,'阿六',true,'assets/images/ima_new_friend.png'));
    _contactsInfos.add(ContactsInfo("A",null,'阿六',true,'assets/images/ima_new_friend.png'));
    _contactsInfos.add(ContactsInfo("A",null,'阿六',true,'assets/images/ima_new_friend.png'));
    _contactsInfos.add(ContactsInfo("A",null,'阿六',true,'assets/images/ima_new_friend.png'));
    _contactsInfos.add(ContactsInfo("A",null,'阿六',true,'assets/images/ima_new_friend.png'));
    _contactsInfos.add(ContactsInfo("A",null,'阿六',true,'assets/images/ima_new_friend.png'));
   
    return Scaffold(
      backgroundColor: Color(AppColors.MainBgColor),
      body: ListView.builder(
        itemBuilder: (BuildContext context,int index){
          return ContactItemLay(iconPath: _contactsInfos[index].imaPath, title:_contactsInfos[index].contactName,hasGroupTitle:_contactsInfos[index].groupIndexTag,hasDivider: true,pressed: ()=>{});
        },
        itemCount: _contactsInfos.length),
        
    );
  }
}

